package org.currentcost;

import java.util.regex.Pattern;

public interface EnviSchema
{
	// 2. Real-Time Output from "Watts" sensors
	//	<msg> start of message
	//	<src>CC128-v1.29</src> source and software version**
	//	<uid>161A582015AA09B</uid> unique ID* (see text†)
	//	<dsb>00089</dsb> days since birth, ie days run
	//	<time>13:02:39</time> 24 hour clock time*
	//	<tmpr>18.7</tmpr> temperature as measured in degC*#
	//	<tmprF>72.3</tmprF> temperature as measured in degF*
	//	<sensor>1</sensor> Appliance Number as displayed
	//	<id>01234</id> radio ID received from the sensor
	//	<type>1</type> sensor Type, "1" = electricity
	//	<ch1> sensor channel*
	//	<watts>00345</watts> data and units
	//		</ch1>
	//	<ch2> sensor channel*
	//	<watts>02151</watts>
	//	</ch2>
	//	<ch3> sensor channel*
	//	<watts>00000</watts>
	//	</ch3>
	//	</msg>

	String MSG = "msg";
	String VERSION = "src";
	String UID = "uid";
	String DAYS_SINCE_BIRTH = "dsb";
	String TIME = "time";
	String TEMPERATURE_CELSIUS = "tmpr";
	String TEMPERATURE_FARENHEIT = "tmprF";
	String APPLIANCE_NUMBER = "sensor";
	String RADIO_ID = "id";
	String SENSOR_TYPE = "type";
	String SENSOR_CHANNEL_PREFIX = "ch";
	Pattern SENSOR_CHANNEL_PATTERN = Pattern.compile("^ch[0-9]+$");
	String WATTS = "watts";

	// 3. Real-Time Output from "Meter Impulse" sensors
	//	<msg> start of message
	//	<src>CC128-v1.29</src> source and software version**
	//	<uid>161A582015AA09B</uid> unique ID* (see previous text†)
	//	<dsb>00089</dsb> days since birth, ie days run
	//	<time>13:02:39</time> 24 hour clock time*
	//	<tmpr>18.7</tmpr> temperature as measured in degC*
	//	<tmprF>72.3</tmprF> temperature as measured in degF*
	//	<sensor>9</sensor> Appliance Number as displayed
	//	<id>01234</id> radio ID received from the sensor
	//	<type>2</type> sensor Type, 2=electric impulse
	//	<imp>0000089466</imp> Meter Impulse Count
	//		<ipu>1000</ipu> Meter Impulses Per Unit
	//	</msg>

	String IMPULSE = "imp";
	String IMPULSE_PER_UNIT = "ipu";

	// 4.1 Two-Hourly History Store
	//	<msg> start of message
	//	<src>CC128-v0.19</src> [as for Real-Time]
	//	<uid>161A582015AA09B</uid> [as for Real-Time]
	//	<dsb>00089</dsb> [as for Real-Time]
	//	<time>13:10:50</time> [as for Real-Time]
	//	<hist> start of history
	//		<dsw>00032</dsw> days since wipe of history
	//		<type>1</type> sensor Type, "1" = electricity
	//	<units>kwhr</units> units of data eg KWHr
	//	<data> start of data burst
	//	<sensor>0</sensor> historic Appliance Number
	//		<h024>001.1</h024> h="hours", 24="22 to 24 hrs ago"
	//	<h022>000.9</h022> h="hours", 22="20 to 22 hrs ago"
	//	<h020>000.3</h020> h="hours", 18="18 to 20 hrs ago"
	//	<h018>000.4</h018> h="hours", 22="16 to 18 hrs ago"
	//	</data>
	//		... [Sensor 1 to 8 data here]
	//	<data>
	//	<sensor>9</sensor>
	//	<units>kwhr</units>
	//	<h024>000.0</h024>
	//	<h022>000.0</h022>
	//	<h020>000.0</h020>
	//	<h018>000.0</h018>
	//	</data>
	//	</hist>
	//	</msg>

	String HISTORY = "hist";
	String DAYS_SINCE_WIPE = "dsw";
	String UNITS = "units";
	String DATA = "data";
	String HOUR_RANGE_PREFIX = "h";
	Pattern HOUR_RANGE_PATTERN = Pattern.compile("^h[0-9]+$");

	//	4.2 Daily History Store
	//	The last 90 days Energy Usage is output as daily aggregates of KWHr (900 values covering 9 Appliances plus 
	// Whole House).
	//	For simplicity, this data overlaps the 2-hr history store in the present version.
	//	"Sensor 0" refers to the "Whole House" and Sensors 1 to 9 are Appliance Sensors.
	//	Where sensors have more than one channel, the value presented is the total of all channels.
	//	<msg>
	//	<src>CC128-v0.19</src>
	//	<uid>161A582015AA09B</uid>
	//	<dsb>00089</dsb>
	//	<time>13:10:50</time>
	//	<hist>
	//	<dsw>00032</dsw>
	//	<type>1</type>
	//	<units>kwhr</units>
	//	<data>
	//	<sensor>0</sensor>
	//	<units>kwhr</units>
	//	<d055>012.9</d055> d="days", 055="55 days ago"
	//	<d054>011.0</d054>
	//	<d053>014.3</d053>
	//	<d052>019.5</d052>
	//	</data>
	//		... [Sensor 1 to 8 data here]
	//	<data>
	//	<sensor>9</sensor>
	//	<units>kwhr</units>
	//	<d055>000.0</d055>
	//	<d054>000.0</d054>
	//	<d053>000.0</d053>
	//	<d052>000.0</d052>
	//	</data>
	//	</hist>
	//	</msg>

	String DAYS_AGO_PREFIX = "d";
	Pattern DAYS_AGO_PATTERN = Pattern.compile("^d[0-9]+$");

	//	4.3 Monthly History Store
	//	The last 84 months Energy Usage is output as monthly aggregates of KWHr (840 values covering 9 Appliances 
	// plus Whole House).
	//	For simplicity, this data overlaps the 2-hr and Daily history stores in the present version [subject to 
	// review].
	//		"Sensor 0" refers to the "Whole House" and Sensors 1 to 9 are Appliance Sensors.
	//	Where sensors have more than one channel this is stored totalled.
	//	<msg>
	//	<src>CC128-v0.19</src>
	//	<uid>161A582015AA09B</uid>
	//	<dsb>00089</dsb>
	//	<time>13:10:50</time>
	//	<hist>
	//	<dsw>00032</dsw>
	//	<type>1</type>
	//	<units>kwhr</units>
	//	<data>
	//	<sensor>0</sensor>
	//	<units>kwhr</units>
	//	<m002>257.0</m002> m="month", 002="2 months ago"
	//	<m001>340.0</m001>
	//	</data>
	//		... [Sensor 1 to 8 data here]
	//	<data>
	//	<sensor>9</sensor>
	//	<units>kwhr</units>
	//	<m002>000.0</m002>
	//	<m001>000.0</m001>
	//	</data>
	//	</hist>
	//	</msg>

	String KWHR = "kwhr";
}
